package main

import (
	"fmt"
	"runtime"
)

func writeChannel(ch chan string) {
	for i := 0; i < 10; i++ {
		ch <- string(rune(i))
	}
	close(ch)
}

func readChannel(ch chan string) {
	//for num:=range ch{
	//	fmt.Println("num=",num)
	//}
	for i := 0; i < 11; i++ {
		fmt.Println("num=", <-ch)
	}
}

func main() {
	ch := make(chan string, 5)
	go writeChannel(ch)
	//go readChannel(ch)
	for i := 0; i < 5; i++ {
		fmt.Println("num=", <-ch)
	}
	for {
		runtime.GC()
	}
}
